#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> student;
	student.resize(n + 1);
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		student[i] = x;
	}
	for(int i = 0; i < m; i++)
	{
		int y;
		cin >> y;
		cout << student[y] << endl;
	}
	return 0;
 } 
